#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QWebEngineView>
#include <QPropertyAnimation>
#include <memory>   // std::shared_ptr

namespace Ui {
class MainWindow;
}

class FormShell;
class FormTestDelete;
class PopMainWnd;

class MainWindow : public QMainWindow
{
    Q_OBJECT
    Q_PROPERTY(qint32 scrollPos READ scrollPos WRITE setScrollPos NOTIFY scrollPosChanged)

public:
    explicit MainWindow(QWidget *parent = Q_NULLPTR);
    ~MainWindow();

    void printDeviceInfo();
    void showPos();

    inline qint32 scrollPos() { return m_scrollPos; }

protected:
    void timerEvent(QTimerEvent *event);
    bool eventFilter(QObject *obj, QEvent *ev) override;

signals:
    void scrollPosChanged();
    void notifyTestSig();

private slots:
    void on_openFileBtn_clicked();

    void on_openFileBtn_w_clicked();

    void on_pushButton_clicked();

    void onNetworkReply(QNetworkReply* reply);

    void on_btn_next_clicked();

    void on_btn_Ani_clicked();

    void on_btn_test_clicked();

    void on_btnTestHover_clicked();

    void on_btnCreateReflectionObj_clicked();

private:
    void showAnimation();

    void getPicByUrl(QString url);

    QPixmap generatePixmap(const QPixmap &src, const int &radius);

    void setScrollPos(qint32 xPos);

    void loadPicByLocal();

    void getLocalDeviceInfo();

private:
    void getJsonInfo(const char* msg);

private:
    Ui::MainWindow *ui;
    QWebEngineView *m_engineView;
    int             m_timerID;

    QPropertyAnimation* m_scrollAnimation = Q_NULLPTR;
    qint32 m_scrollPos = 0;
    std::unique_ptr<FormShell>      m_uPtrShell;
    std::unique_ptr<FormTestDelete> m_uPtrTest;
    PopMainWnd*                     m_pPopMainWnd = Q_NULLPTR;
};

#endif // MAINWINDOW_H
